// guessthenumber.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
#include <time.h>
// Generate the random number
	int number = 50;
	// set the game variable to 1 when it is one the game loop runs
	int game = 1;
	// initilize the numberguessed variable
	int numberguessed = -1;

//Generates a random number
int gen_ran_num()
{
	srand(time(NULL));
	int ran_num = rand() % 101;
	return ran_num;
}
// Checks the number guessed and does shit according
void checknumber(int numbertocheck, int realnumber)
{
	using namespace std;
	if(numbertocheck == realnumber)
	{
		game = 0;
	}
	if(numbertocheck < realnumber)
	{
		cout << "The number I am thinking of is higher then the one you guessed" << endl;
	}
	if(numbertocheck > realnumber)
	{
		cout << "The number I am thinking of is lower then the one you guessed" << endl;
	}
}
int main(){
	using namespace std;
	number = gen_ran_num();
	cout << "I am thinking of a number between 1 and 100" << endl << "Make a guess " << endl;
	// runs the input and checking repeatedly until the correct number is guessed
	while (game == 1){
	cin >> numberguessed;
	checknumber(numberguessed, number);
	}
	if (game == 0){
	cout << "Congratulations! The number I was thinking of was " << number << "." << endl;
	}
}
